<?php
$isReloadable = true;
$isPopUp = true;
require_once "../../../pers/inc.config.php";
require_once OVF_FS_WEB_ROOT.'/app/_inc/inc.session.php';
require_once OVF_FS_WEB_ROOT.'/app/_inc/funct.html.php';
require_once OVF_FS_WEB_ROOT.'/app/_inc/class.ovfForm.php';
require_once OVF_FS_WEB_ROOT.'/app/_inc/class.ovfLista.php';

$objSess->setReqSV('rcom', 'idAnag', 0);
$idAnag = intval($objSess->getSV('rcom', 'idAnag'));
$objSess->setReqSV('rcom', 'asez', 'referent');
$codSez = $objSess->getSV('rcom','asez');

$oFormTestasez = new ovfForm('testasez');
$oListsez = new ovfLista($codSez);

$sSql = "SELECT ".$oFormTestasez->getCampiSelect()." FROM ovf_anagrafiche A "
	." WHERE A.id_anag = ".$idAnag;
$objDB->query($sSql);
if (!$oFormTestasez->aCampiDB = $objDB->fetch()) {
	die("id. errato '".$idAnag."'");
}
$oFormTestasez->db2form();

$oFormTestasez->oDocGen = new ovfDocGen();
$oFormTestasez->oDocGen->maxCol = 40;
$oFormTestasez->oDocGen->pdfIntestaz = $oFormTestasez->aCampiDB['A_intestaz1'];
$txt12 = 'txt1';

$oFormTestasez->oDocGen->nuovaRiga();
$aCol = array('cla'=>'tit1');
$aCol['col']=40;
$aCol['alg']='C';
$aCol['txt'] = _t('ANAGRAFICA');
$oFormTestasez->oDocGen->setCol($aCol);

$oFormTestasez->setDocGen();

$oListsez->oDocGen = $oFormTestasez->oDocGen;
$oListsez->oDocGen->nuovaRiga();
$aCol = array('cla'=>'tit1');
$aCol['col']=40;
$aCol['alg']='C';
$aCol['txt'] = _t($oListsez->descr);
$oListsez->oDocGen->setCol($aCol);
$oListsez->setDocGenLab();
$sSql = "SELECT ".$oListsez->getCampiSelect('S')." FROM ovf_sez_$codSez S "
	." WHERE S.id_anag = ".$idAnag;
$objDB->query($sSql);
while ($aRow = $objDB->fetch()) {
	$oListsez->setDocGenDat($aRow);
}
$sPdf = $oListsez->oDocGen->genPdf();

headerDownLoad(strlen($sPdf),_t($codSez)."_all_".$oFormTestasez->aCampiDB['A_id_anag'].".pdf");
echo $sPdf;
exit();
